CC:=clang++
CLANG++VERSION:=$(shell clang++ -dumpversion)
CLANG_LIBCPP_INCS = -I/usr/gcc-4.7.2/include/c++/4.7.2/x86_64-linux-gnu -I/usr/gcc-4.7.2/include/c++/4.7.2/

ifdef GCC
CC:=g++
CLANG_LIBCPP_INCS =
endif

CPPFLAGS = -Wall -W -g -pedantic -O2

TESTS:=$(wildcard tests/*.cpp)
EXES:=$(TESTS:.cpp=)


%: %.cpp
	$(CC) $(CLANG_LIBCPP_INCS) $(CPPFLAGS) -D__DEBUG__=1 -std=c++11 $< -o $@

all: $(EXES)

test: $(EXES)
	rm -f tests/test.log
	for c in $(EXES); do \
		echo "Testing " ./$$c >> tests/test.log; \
		echo -n "Testing " ./$$c ; \
		./$$c >> tests/test.log ; \
		if [ $$? -eq 0 ] ; then echo "\t -> PASSED" ; fi \
	done


clean:
	rm -f $(EXES) *~ tests/*~ tests/*log